#pragma once

enum task_state {
  TASK_RUNNING = 0, /* Ready state */
  TASK_INTERRUPTIBLE /* Interruptable sleep state */
};

struct task {
  unsigned long id;
  enum task_state state;
  unsigned long rip; /* (VA) Instruction address */
  unsigned long rsp0; /* (VA) Kernel stack top address */
  unsigned long kstack; /* (VA) Kernel stack address */
  unsigned long pml4; /* (PA) Process level 4 root page table address */

  struct task* next;
  struct task* prev;
};

struct timer {
  unsigned long alarm; // Expiration clock tick count => equivalent to expiration time
  struct task* task;
  
  struct timer* next;
  struct timer* prev;
};


extern struct task* current;
extern void* task0_stack; // defined in head64.S

extern void idle_task_entry(); // defined in head64.S
extern void ret_from_kernel(); // defined in head64.S
void sched_init();